package com.abkj.platform.tail.util;

import java.io.PrintStream;
import java.util.Date;
import org.apache.commons.codec.binary.Base64;

public class Base64Util
{
  public static final String key = "ABKJ-PT";

  public static String encodeStr(String key, String plainText)
  {
    plainText = key + plainText;
    byte[] b = plainText.getBytes();
    Base64 base64 = new Base64();
    b = base64.encode(b);
    String s = new String(b);
    return s;
  }

  public static String decodeStr(String encodeStr) {
    byte[] b = encodeStr.getBytes();
    Base64 base64 = new Base64();
    b = base64.decode(b);
    String s = new String(b);
    return s;
  }

  public static String encodePwd(String pwd) {
    return encodeStr("ABKJ-PT", pwd);
  }

  public static void main(String[] args) {
    long d = DateUtil.strToLong("20140731000000", "yyyyMMddHHmmss");
    String ed = encodeStr("ABKJ-TAIL-0001", String.valueOf(d));
    System.out.println("激活码is：" + ed);
    String de = decodeStr("QUJLSi1UQUlMLTAwMDExNDA2NzM2MDAwMDAw");
    System.out.println(de);
    System.out.println(new Date(1406736000000L));
  }
}